home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / pctchnqs / 1990 / number3 / capslock.pas < prev    next >
Pascal/Delphi Source File  |  1990-04-19  |  739b  |  36 lines

  1. PROGRAM CapsLock;
  2.  
  3. USES
  4.   Crt;
  5.  
  6. VAR
  7.   Ch : char;
  8.  
  9. FUNCTION ReadChar : char;
  10. {
  11.   Replacement for ReadKey.
  12.   Automatically flushes CapsLock whenever ShiftKey is hit.
  13. }
  14.  
  15. VAR
  16.   LocalCh : char;
  17.   KeyStateByte : byte absolute $40:$17;      { status of shift keys }
  18.  
  19. BEGIN
  20.   LocalCh := ReadKey;
  21.   If KeyStateByte and 3 > 0 then             { if either shift then }
  22.     begin
  23.       LocalCh := UpCase (LocalCh);           { upcase ch }
  24.       KeyStateByte := KeyStateByte and $BF;  { turn off capslock }
  25.     end;
  26.   ReadChar := LocalCh;                       { return char }
  27. END;
  28.  
  29. BEGIN                                        { test program }
  30.   Repeat
  31.     Ch := ReadChar;
  32.     Write (Ch)
  33.   until
  34.     Ch = #13;
  35. END.
  36.